<script setup lang="ts">
import { ref } from 'vue'
import Icon from '../Icon/Icon.vue'
defineOptions({
  name: 'VkButton'
})
import type { ButtonProps } from './type'

withDefaults(defineProps<ButtonProps>(), {
  nativeType: 'button'
})
const _ref = ref<HTMLButtonElement>()
defineExpose({
  ref: _ref
})
</script>

<template>
  <button
    ref="_ref"
    class="vk-button"
    :class="{
      'is-round': round,
      'is-plain': plain,
      'is-circle': circle,
      'is-disabled': disabled,
      [`vk-button--${type}`]: type,
      [`vk-button--${size}`]: size
    }"
    :disabled="disabled || loading"
    :type="nativeType"
    :autofocus="autofocus">
    <Icon icon="spinner" spin v-if="loading" />
    <Icon :icon="icon" v-if="icon" />
    <span><slot></slot></span>
  </button>
</template>

<style scoped></style>
